from django.db import models

# Create your models here.


from django.db import models
# 获得基本用户模型类
from django.contrib.auth import get_user_model

User = get_user_model()


class AuthenticationStatus(models.IntegerChoices):
    NOT_AUTHENTICATED = (1, '未认证')
    AUTHENTICATDING = (2, '正在认证')
    AUTHENTICATED = (3, '已认证')
    AUTHENTICATED_FAIL = (4, '认证失败')


class SchoolMateProfile(models.Model):
    """
    数据库中存放的校友档案表
    这个应该是,
    """
    # 认证所需字段
    user = models.OneToOneField(User, on_delete=models.CASCADE, related_name='SMprofile', blank = True)
    name = models.CharField(max_length=10, verbose_name='校友姓名', help_text='校友姓名')
    mobile = models.CharField(verbose_name='电话号码', max_length=11,
                              unique=True, db_index=True, null=True, blank=True)
    is_full_time = models.BooleanField(
        verbose_name='是否全日制', null=True, blank=True)
    attendance_date = models.DateField(verbose_name='入学日期')
    major = models.CharField(verbose_name='专业', max_length=12)
    class_name = models.CharField(verbose_name='班级', max_length=12)
    student_id = models.CharField(
        verbose_name='学号', unique=True, db_index=True, max_length=20)
    institute_name = models.CharField(verbose_name='学院', max_length=12)

    def __str__(self):
        return self.name

    # 其他字段

    class Meta:
        verbose_name = '校友信息'
        verbose_name_plural = '校友信息'


class NeedAuthenticatedSchoolMateProfile(models.Model):
    """
    用户上传待认证档案, 需要认证
    """

    # 记录谁提交的
    user = models.OneToOneField(User, on_delete=models.CASCADE, related_name='profile')

    # 需要提交的字段
    name = models.CharField(max_length=10, verbose_name='校友姓名', help_text='校友姓名')

    mobile = models.CharField(verbose_name='电话号码', max_length=11,
                              unique=True, db_index=True, null=True, blank=True)
    attendance_date = models.DateField(verbose_name='入学年份')
    major = models.CharField(verbose_name='大学专业', max_length=12)
    class_name = models.CharField(verbose_name='班级名称', max_length=12)
    student_id = models.CharField(verbose_name='学号', max_length=20)
    institute_name = models.CharField(verbose_name='学院', max_length=12)
    # 记录状态字段
    authentication_status = models.IntegerField(
        choices=AuthenticationStatus.choices, default=1)

    # 自带的
    create_date = models.DateTimeField(verbose_name='创建时间', auto_now_add=True)

    def __str__(self):
        return self.name

    class Meta:
        verbose_name = '用户信息'
        verbose_name_plural = '用户信息'
